package com.yidi.common.core.domain.entity;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

import com.yidi.common.core.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @author ：Xn
 * @ClassName: SysDept
 * @date ：2021-10-18 14:15
 * @describe ：部门表
 */
@Getter
@Setter
@Entity
@Table(name = "sys_dept")
@ToString(callSuper=true)
public class SysDept extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 父部门ID */
    @Column(name = "parent_id")
    private Long parentId;

    /** 祖级列表 */
    private String ancestors;

    /** 部门名称 */
    @NotBlank(message = "部门名称不能为空")
    @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
    @Column(name = "dept_name")
    private String deptName;

    /** 负责人 */
    private String leader;

    /** 联系电话 */
    @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
    private String phone;

    /** 邮箱 */
    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    private String email;

    /** 部门状态:0正常,1停用 */
    private String status;

    /** 父部门名称 */
    @Transient //不在数据库中做映射
    private String parentName;
    
    /** 子部门 */
    @Transient //不在数据库中做映射
    private List<SysDept> children = new ArrayList<SysDept>();

}
